package models

import (
	t "yikexing.com.cn/wyws/services/sqlstore/types"
	"time"
)

/**
字典domain
 */
type Dict struct {
	Id              uint64             `db:"id" description:"主键"`
	Value           string             `db:"value" description:"数据值"`
	Label           string             `db:"label" description:"标签名"`
	DictType        string             `db:"dict_type" description:"类型"`
	Description     string             `db:"description" description:"描述"`
	Sort            int                `db:"sort" description:"排序"`

	CreatedUserName string             `db:"created_user_name" description:"记录创建者"`
	LastUpdatedUser string             `db:"last_updated_user" description:"记录修改者"`
	Validity        bool               `db:"validity" description:"数据有效性(默认都是有效的)"`
	DateCreated     t.TimeMillisecond  `db:"date_created" description:"记录创建时间"`
	LastUpdated     t.TimeMillisecond  `db:"last_updated" description:"记录最后修改时间"`
}

/**
创建和修改 用到的command
 */
type DictCommand struct {
	Value       string    `valid:"Required" required:"true" description:"数据值"`         // 数据值
	Label       string    `valid:"Required" description:"标签名"`                         // 标签名
	DictType    string    `valid:"Required" description:"类型(同一个类型的字典,value和label要唯一)"` // 类型 (0:系统保留, 1:用户自定义),系统保留的字段不可以删除.默认为用户自定义
	Description string    `description:"描述"`                                           // 描述
	Sort        int       `description:"排序"`                                           // 排序
}

type DictResult struct {
	Id              int     `description:"主键"`
	Value           string  `description:"数据值"` // 数据值(唯一的)
	Label           string  `description:"标签名"` // 标签名
	DictType        string  `description:"类型"`  // 类型 (同一个类型的字典,value和label要唯一)
	Description     string  `description:"描述"`  // 描述
	Sort            int     `description:"排序"`  // 排序

	CreatedUserName string  `description:"记录创建者"`
	LastUpdatedUser string  `description:"记录修改者"`
	DateCreated     int64   `description:"记录创建时间"`
	LastUpdated     int64   `description:"记录最后修改时间"`
}

type AddDict struct {
	DictCommand DictCommand
	DictResults DictResults
}

type GetAllDict struct {
	DictType    string `db:"dict_type" valid:"Min(0)" description:"字典类型"`

	Max         int   `db:"max" valid:"Min(0)" description:"获取最大条数"`
	Offset      int   `db:"offset" valid:"Min(0)" description:"起始位置"`
	DictResults DictResults
}

type GetDictDetail  struct {
	Id     int
	Result DictResults
}

type DictResults struct {
	Total  int
	Result []Dict
}

type UpdateDict struct {
	Id         	int	      `db:"id" description:"主键"`
	Value      	string        `db:"value" description:"数据值"`
	Label      	string        `db:"label" description:"标签名"`
	DictType   	string        `db:"dict_type" description:"类型"`
	Description	string        `db:"description" description:"描述"`
	Sort       	int           `db:"sort" description:"排序"`
	CreatedUserName string        `db:"created_user_name" description:"记录创建者"`
	LastUpdatedUser string        `db:"last_updated_user" description:"记录修改者"`
	Validity        bool          `db:"validity" description:"数据有效性(默认都是有效的)"`
	DateCreated     time.Time     `db:"date_created" description:"记录创建时间"`
	LastUpdated     time.Time     `db:"last_updated" description:"记录最后修改时间"`

	DictResults DictResults
}

type DeleteDict struct {
	Id int
}
